Working with Java using methods and arrays [closed]

Posted by jordan on Stack Overflow See other posts from Stack Overflow or by jordan
Published on 2012-03-23T23:09:24Z Indexed on 2012/03/23 23:30 UTC
Read the original article Hit count: 180

Filed under:
|

Hi i'm a newb at java and for one of my labs I have to create a instant messenger client with these requirements:

  • add buddyList instance variable
  • add IMClient constructor to create ArrayList
  • addBuddy method
  • removeBuddy method
  • findBuddy method
  • printBuddyList method

what's the best way to go about this? so far I have this:

        public class IMClient 
{   
    private String userId;          // User id
    private String password;        // Password
    private int status;             // Status code for user: 1 - Online, 2 - Off-line, 3 - Away

    public IMClient(String userId, String password, int status)
    {
        super();
        this.userId = userId;
        this.password = password;
        this.status = status;
    }

    // Returns true if password as a parameter matches password instance variable.
    public boolean checkPassword(String password)
    {
        return this.password.equals(password); 
    }

    public String toString()
    {   StringBuffer buf = new StringBuffer(100);               
        buf.append(" User id: ");
        buf.append(userId);
        buf.append(" Password: ");
        buf.append(password);
        buf.append(" Status: ");
        buf.append(status);
        return buf.toString();
    }

    public String getUserId()
    {
        return userId;
    }

    public void setUserId(String userId)
    {
        this.userId = userId;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }

    public static void main(String[] args) 
    {

    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about homework